<template>
  <view class="_search-wrapper">
      <view class="_search-input-box">
        <icon class="_search-icon" type="search" size="14" />
        <input
          :value="value"
          @input="keyInput"
          :placeholder="placeholder"
          placeholder-style="color:#A9A9A9;"
          class="_search-input"
          autocapitalize />
        <icon v-show="value" @tap="clearInput" class="icon-clear" type="clear" size="14" />
      </view>
    </view>
</template>

<script setup>
  const { showTitle} = defineProps({
    showTitle: {
      type: Boolean,
      default: false
    },
    buttonText: {
      type: String,
      default: '搜索'
    },
    value: {
      type: String,
      default: ''
    },
    searchText: {
      type: String,
      default: '搜索'
    },
    placeholder: {
      type: String,
      default: '请输入搜索关键字',
    },
  });
  const emit = defineEmits(['onSearch', 'onInput']);
  

  const keyInput = (e) => {
    emit("onInput", e.detail.value);
  }

</script>

<style lang="scss">
._search-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    ._search-input-box {
      position: relative;
      display: flex;
      flex: 1;
      border-radius: 23upx;
      justify-content: flex-start;
      align-items: center;
      padding: 16upx 24upx;
      background: #f5f5f5;
      color: #1f1f1f;
      ._search-input {
        flex: 1;
        background: #f5f5f5;
        outline: none;
        height: 36upx;
        margin-left: 22upx;
        margin-right: 22upx;
        font-weight: 400;
        font-size: 26upx;
        line-height: 36upx;
        color: #1F1F1F;
      }
    }
    .clear-text {
      padding-left: 40upx;
      font-weight: 400;
      font-size: 26upx;
      line-height: 36upx;
      text-align: right;
      color: #CDCDCD;
      &.focus {
        color: #1f1f1f;
      }
    }
  }
</style>